﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进入页面弹出收藏夹</title>
    <script type="text/javascript" language="JavaScript">
        let expDays = 7;
        url = "http://www.google.com/";
        title = "收藏夹特效";
        // 获取Cookie中保存的信息
        function GetCookie (name)
        {
            let arg = name + "=";
            let alen = arg.length;
            let clen = document.cookie.length;
            let i = 0;
            while (i < clen) {
                let j = i + alen;
                if (document.cookie.substring(i, j) === arg)
                    return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i === 0) break;   }
            return null;
        }
        // 保存信息到Cookie中
        function SetCookie (name, value)
        {
            let argv = SetCookie.arguments;
            let argc = SetCookie.arguments.length;
            let expires = (argc > 2) ? argv[2] : null;
            let path = (argc > 3) ? argv[3] : null;
            let domain = (argc > 4) ? argv[4] : null;
            let secure = (argc > 5) ? argv[5] : false;
//设置cookie的属性：有效期、域、路径等
            document.cookie = name + "=" + escape (value) +
                ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) +
                ((path === null) ? "" : ("; path=" + path)) +
                ((domain === null) ? "" : ("; domain=" + domain)) +
                ((secure === true) ? "; secure" : "");
        }
        //删除指定的Cookie
        function DeleteCookie (name)
        {
            let exp = new Date();
            exp.setTime (exp.getTime() - 1);
            let cval = GetCookie (name);
            document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
        }
        let exp = new Date();
        exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
        function amt(){
            let count = GetCookie('count')
            if(count === null) {
                SetCookie('count','1')
                return 1
            }
            else {
                let newcount = parseInt(count) + 1;
                DeleteCookie('count')
                SetCookie('count',newcount,exp)
                return count
            }
        }
        function getCookieVal(offset)
        {
            let endstr = document.cookie.indexOf (";", offset);
            if (endstr === -1)
                endstr = document.cookie.length;
            return unescape(document.cookie.substring(offset, endstr)); //解密Cookie中的信息
        }

        function checkCount()
        {
            let count = GetCookie('count');
//如果已经在收藏夹中添加了网站，则下一次不再出现添加收藏夹界面
            if (count === null) {
                count=1;
                SetCookie('count', count, exp);
                if ((navigator.appName === "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
                {
                    window.external.AddFavorite (url,title);  //打开收藏夹的关键语句
                }
            }
            else {
                count++;
                SetCookie('count', count, exp);
            }
        }
        checkCount();
    </script>
</head>
<body bgcolor="#ffffff" onLoad="window.setTimeout('getSecs()',1)">

</body>
</html>